StupidBeauty
Read times:1201Posted at:Fri Apr 18 00:41:38 2014
- no title specified

转载 Undefined reference to static class member

对于类中的静态成员变量,必须在类之外的某处实际定义一下,否则编译时将会“undefined reference to static class member”。

http://stackoverflow.com/questions/272900/undefined-reference-to-static-class-member

亮点:


115
down vote accepted

You need to actually define the static member somewhere (after the class definition). Try this:

class Foo { /* ... */ };

const int Foo::MEMBER;

int main() { /* ... */ }

That should get rid of the undefined reference.

share | improve this answer

edited Jan 4 at 21:37

user529758

answered Nov 7 '08 at 17:57

Drew Hall
15.1k 53552

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands